import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:smart_translator/app/style/widget_style.dart';
import 'package:smart_translator/app/views/controller/rt_call_controller.dart';

import '../../modules/videoCall/controller/video_calling_controller.dart';
import '../../routes/app_pages.dart';
import '../../widgets/CommonWidgets.dart';

class RtCallView extends GetView<RtCallController> {
  const RtCallView({super.key});

  @override
  Widget build(BuildContext context) {
    return SafeArea(
      top: false,
      child: Scaffold(
        resizeToAvoidBottomInset: false,
        body: Obx(
          () => Padding(
            padding: EdgeInsets.only(left: 20.0, right: 20.0),
            child: Column(
              children: [
                Container(
                  margin: EdgeInsets.only(top: 30.h),
                  height: 100.h,
                  child: Column(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: [
                      Row(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        children: [
                          Expanded(
                            child: Center(
                              child: Text(
                                '视频通话',
                                style: TextStyle(
                                  fontSize: 16,
                                  color: Color((0xFF333333)),
                                  fontWeight: FontWeight.w900,
                                ),
                              ),
                            ),
                          ),
                          InkWell(
                            onTap: () {},
                            child: Image.asset(
                              'assets/images/icon_index_record.png',
                              width: 16.w,
                              height: 16.h,
                            ),
                          ),
                        ],
                      ),
                    ],
                  ),
                ),

                Container(
                  width: Get.width,
                  // margin: EdgeInsets.only(top: 100.h),
                  child: Column(
                    children: [
                      // 语言选择区域开始
                      Container(
                        width: Get.width,
                        padding: EdgeInsets.all(18.w),
                        decoration: BoxDecoration(
                          boxShadow: [
                            CommonWidgets.getBoxShadow()
                          ],
                          color: Colors.white,
                          borderRadius: BorderRadius.circular(
                            8,
                          ), // Optional: add border radius
                        ),
                        child: Column(
                          children: [
                            InkWell(
                              onTap: () {
                                controller.chooseFromLanguages();
                              },
                              child: Row(
                                mainAxisAlignment:
                                    MainAxisAlignment.spaceBetween,
                                children: [
                                  Row(
                                    children: [
                                      Text(
                                        '我方语言',
                                        style:
                                            AppStyleThemeData.BUTTON_TEXT_STYLE,
                                      ),
                                    ],
                                  ),

                                  Row(
                                    children: [
                                      Text(
                                        controller.fromLanFlagDisplay.value,
                                        style:
                                            AppStyleThemeData.HINT_TEXT_STYLE,
                                      ),
                                      Image.asset(
                                        'assets/images/icon_mine_right_item.png',
                                        width: 24.w,
                                        height: 24.h,
                                      ),
                                    ],
                                  ),
                                ],
                              ),
                            ),

                            SizedBox(height: 12.h),
                            CommonWidgets.getMyDivider(),
                            SizedBox(height: 12.h),

                            InkWell(
                              onTap: () {
                                controller.chooseToLanguages();
                              },
                              child: Row(
                                mainAxisAlignment:
                                    MainAxisAlignment.spaceBetween,
                                children: [
                                  Row(
                                    children: [
                                      Text(
                                        '对方语言',
                                        style:
                                            AppStyleThemeData.BUTTON_TEXT_STYLE,
                                      ),
                                    ],
                                  ),

                                  Row(
                                    children: [
                                      Text(
                                        controller.toLanFlagDisplay.value,
                                        style:
                                            AppStyleThemeData.HINT_TEXT_STYLE,
                                      ),
                                      Image.asset(
                                        'assets/images/icon_mine_right_item.png',
                                        width: 24.w,
                                        height: 24.h,
                                      ),
                                    ],
                                  ),
                                ],
                              ),
                            ),
                          ],
                        ),
                      ),
                      // 语言选择区域结束
                      SizedBox(height: 20.h),

                      // 通话类型选择开始
                      Row(
                        mainAxisAlignment: MainAxisAlignment.spaceAround,
                        children: [
                          Row(
                            children: [
                              Radio<String>(
                                value: 'video',
                                groupValue: controller.rtCallType.value,
                                onChanged: controller.changeCallType,
                              ),
                              Text('视频通话'),
                            ],
                          ),
                          SizedBox(width: 20),
                          Row(
                            children: [
                              Radio<String>(
                                value: 'voice',
                                groupValue: controller.rtCallType.value,
                                onChanged: controller.changeCallType,
                              ),
                              Text('语音通话'),
                            ],
                          ),
                        ],
                      ),
                      SizedBox(height: 20.h),
                      Container(
                        width: 594.w,
                        child:ElevatedButton.icon(
                          onPressed: controller.handleInvite,
                          icon: Image.asset('assets/images/video_invite.png'),
                          label: Text("邀请好友通话"),
                        ),
                      ),
                      SizedBox(height: 16.0),
                      Text(
                        '通过网页链接加入通话',
                        style: TextStyle(
                          color: Color((0xFF8A8A8E)),
                          fontSize: 14.sp,
                        ),
                      ),
                    ],
                  ),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
